Skip to content

Prefer canonical qualified names for classes under Thread - #867

Closed
nobu wants to merge 3 commits into
ruby:masterfrom
nobu:qualified-thread-classes
Closed

nobu wants to merge 3 commits into
ruby:masterfrom
nobu:qualified-thread-classes

Conversation

@nobu

@nobu nobu commented Oct 9, 2021 •

Copy link
Copy Markdown
Member

As the names show, Mutex, Queue, SizedQueue and ConditionVariable are defined under the Thread namespace, and the top level constants are aliases.
Not to cause confusion, bundled files should use the canonical qualified names at least.

@eregon

eregon commented Oct 11, 2021

Copy link
Copy Markdown
Member

What is the motivation behind this change?

AFAIK most users don't prefix with Thread:: for Queue and Mutex (unless the code is quite old).

I also don't think we can ever remove those top-level constants without causing major compatibility issues.

@eregon

eregon commented Oct 11, 2021

Copy link
Copy Markdown
Member

On CRuby I see:

$ ruby -e 'p Queue'
Thread::Queue
$ ruby -e 'p Mutex'
Thread::Mutex

but on TruffleRuby:

$ ruby -e 'p Queue'
Queue
$ ruby -e 'p Mutex'
Mutex

I don't think it matters too much, but IMHO since the recent usages are predominantly without Thread:: I think that should be the canonical name.

@eregon

eregon commented Oct 11, 2021

Copy link
Copy Markdown
Member

I've merged a9430c7 since that change makes sense no matter what we do next.

@nobu
nobu force-pushed the qualified-thread-classes branch from 2a0eaf1 to 5d7b1c6 Compare October 12, 2021 01:47
@eregon

eregon commented Oct 15, 2021

Copy link
Copy Markdown
Member

@nobu Could you explain the motivation behind this change?

@nobu
nobu force-pushed the qualified-thread-classes branch from 5d7b1c6 to fa834ad Compare October 17, 2021 22:43
@nobu

nobu commented Oct 19, 2021

Copy link
Copy Markdown
Member Author

@eregon Filled the description.

@nobu
nobu force-pushed the qualified-thread-classes branch from fa834ad to 57d02e9 Compare October 19, 2021 07:54
@eregon

eregon commented Oct 19, 2021

Copy link
Copy Markdown
Member

@nobu Thanks, I think we should change the canonical names instead so they represent the usages better: https://bugs.ruby-lang.org/issues/18256

@eregon

eregon commented Oct 8, 2022

Copy link
Copy Markdown
Member

Thank you for the PR. I decide to close this. AFAIK most usages by Ruby users are without the Thread:: prefix, and nesting seems to just make it harder to find specs for Mutex/Queue/SizedQueue (+ potential needless conflicts).

@eregon eregon closed this Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants